<template>
  <div class="out_container">
    <button v-model="isShowAllWord" @click="isShowAllPic" class="button">
      {{ isShowAllWord }}
    </button>
    <div v-show="isShowAll">
      <div v-for="item in floorList" :key="item.bannerType">
        <h1>{{ item.typeName }}</h1>
        <button @click="isShowPic(item.bannerType)" class="button">
          {{
            thisIndex == item.bannerType ? "隐藏该相册图片" : "展示该相册图片"
          }}
        </button>
        <div
          ref="name"
          class="container"
          v-show="thisIndex == item.bannerType"
          :id="item.bannerType"
        >
          <img
            v-for="subItem in item.bannerImg"
            :key="subItem.id"
            :src="subItem.imgUrl"
            class="floor_img"
          />
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapState } from "vuex";
export default {
  name: "",
  data() {
    return {
      isShowAll: true, //是否隐藏所有相册
      isShowAllWord: "隐藏所有相册",
      thisIndex: "",
    };
  },
  mounted() {
    this.$store.dispatch("getFloorList");
  },

  methods: {
    // 是否展示所有图片
    isShowAllPic() {
      this.isShowAll = !this.isShowAll;
      if (this.isShowAll) {
        this.isShowAllWord = "隐藏所有相册";
      } else this.isShowAllWord = "展示所有相册";
    },
    // 根据传入的bannerType来决定是否展示该相册图片
    isShowPic(bannerType) {
      if (this.thisIndex == bannerType) {
        this.thisIndex = "";
      } else {
        this.thisIndex = bannerType;
      }
    },
  },
  computed: {
    ...mapState({
      floorList: (state) => state.mypic.floorList,
    }),
  },
};
</script>

<style lang="less" scoped>
.out_container {
  margin-left: 2px;
  margin-top: 2px;
  h1 {
    font-size: 24px;
    font-family: STXingkai;
    margin-left: 15px;
    font-weight: normal;
    margin-bottom: 1px;
  }
  .container {
    width: 100%vw;
    overflow: hidden;
    margin-top: 10px;
    margin-left: 20px;
    .floor_img {
      width: 170px;
      height: 120px;
      margin: 3px 5px;
      border: 4px solid skyblue;
      float: left;
    }
    .test {
      float: left;
    }
  }
}
.button {
  width: 150px;
  height: 40px;
  border: none;
  background-color: rgba(175, 206, 252, 0.3);
  font-size: 16px;
  border-radius: 25px;
}
.button:hover {
  background-color: rgba(175, 206, 252, 1);
}
</style>